package com.qa.controller;

import com.qa.service.ICategoryArticleService;
import com.qa.vo.CategoryArticleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Author
 * @Date 2020/3/12 22:22
 * @Desc
 **/
@Controller
public class CategoryArticleController {

    @Autowired
    private ICategoryArticleService categoryArticleService;

    @PostMapping("/cms/categoryArticle/add")
    public void test(@RequestParam("text") String text) {
        categoryArticleService.add(text);

    }

    @GetMapping("categoryArticle/detail")
    public String categoryArticleDetail(@RequestParam("categoryId") Integer categoryId, Model model) {
        List<CategoryArticleVo> categoryArticleVos = categoryArticleService.getByCategoryId(categoryId);
        model.addAttribute("categoryArticleVos", categoryArticleVos);
        return "categoryArticle";
    }
}
